const mongoose = require('mongoose');
const Schema = mongoose.Schema;

let ObjectId = Schema.Types.ObjectId;

/*
*  model，即一个对象的具体结构，这些字段也将写进数据库
* */

// 创建userSchema
const orderSchema = new Schema({
  orderNo: {type: ObjectId, required: true},
  consumer: {type: String, required: true}, // 订单创建者
  goods: {type: String}, // 商品
  goodsId: {type: Number, required: true},
  money: {type: Number, required: true},
  createTime: {type: Date, default: Date.now()}, // 订单创建时间
  payTime: {type: Date, required: true}, // 支付时间
});

// 发布model模型 这里的order对应数据库中的集合
const Order = mongoose.model("order", orderSchema);
module.exports = Order;
